{extend name="public:base"}
{block name='css'}
{/block}

{block name='body'}
<div class="view view-main white-navbar white-toolbar">
    <div data-name="home" class="page">

        <div class="navbar">
            <div class="navbar-inner">
                <div class="left"><a href="{$my_prev_url|default='/'}" class="external"><i class="iconfont icon-fanhui"></i></a></div>
                <div class="center"><span>添加订单({:session('user_goods.name')})</span></div>
                <div class="right"></div>
            </div>
        </div>

        <div class="page-content  padding-bottom50">

            <div class="jiesuan">
                <div class="goods">
                    {volist name='goods_list' id='vo'}
                    <div class="mt">
                        <img src="{$vo.img}" alt="" />
                        <div class="y">
                            <p class="p1">{$vo.title}</p>
                            <p class="p2"><span>￥{$vo.unit_price}</span>x {$vo.num}</p>
                        </div>
                    </div>
                    {/volist}
                </div>

                <div class="jie">
                    <p class="p2" style="margin:0px;">
                        <span class="sp2 y" style="color:#ff4242;font-size:16px;">￥{$order_amount}</span>
                        <span class="sp1 y">合计价格：</span>
                    </p>
                </div>

                <form id="js-place">
                    <input type="hidden" name="goods_id" value="{$_POST.goods_id|implode=',',###}"/>
                    <input type="hidden" name="num" value="{$_POST['num'][session('user_goods.user_id')]|implode=',',###}"/>
                </form>

            </div>

            <div class="block">
                <p class="row segmented-round">
                    <button class="col button button-big button-fill " onclick="toPay();" style="background:#66ba61;">提交订单</button>
                </p>
            </div>

        </div>


    </div>
</div>
{/block}

{block name="js"}
<script>
    var ajaxOn = false;
    function toPay() {
        if (ajaxOn) {
            return false;
        }
        ajaxOn = true;
        $.post("{:url('user_place')}", $('#js-place').serialize(), function(data){
            ajaxOn = false;
            messageToast(data.info);
            if(data.status == 'y'){
                //订单创建成功 跳转
                setTimeout(function () {
                    self.location = "{:url('manage')}";
                }, 1000);
            }
        }, 'json');
    }
</script>
{/block}